package util;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;


@Slf4j
public class Helper {
    public static int getIdFromRequest(HttpServletRequest request) {
        return getIdFromRequest(request, "id");
    }

    public static int getIdFromRequest(HttpServletRequest request, String fieldName) {
        String fieldPara = request.getParameter(fieldName);
        return Integer.parseInt(fieldPara);
    }

    /**
     * @param logicView 逻辑视图
     * @return 物理视图
     */
    public static String resolve(String logicView) {
        return "/WEB-INF/pages/" + logicView + ".jsp";
    }

    //为字串两端加引号
    public static String quote(String str) {
        return "\"" + str + "\"";
    }


//    public static void main(String[] args) {
//        log.debug(Helper.quote("schools:"));
//    }
}
